<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>部门管理</title>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	
</head>
    <script type="text/javascript" src="js/jquery-1.12.4.js"></script>
    <script type="text/javascript">
       function getall()
       {
          $.getJSON("dept/apply-list.action","",function(res){
          for(var i=0;i<res.length;i++)
          {
            
              var newtr=$("<tr class='text-c'></tr>");
             /*  newtr.append("<td><input type='checkbox' value='1' name=''></td>"); */
              newtr.append("<td class='deptid' >"+res[i].de_id+"</td>");
              newtr.append("<td>"+res[i].de_name+"</td>");
              newtr.append("<td>"+res[i].de_manager.us_name+"</td>");
              newtr.append("<td>"+res[i].de_changer.us_name+"</td>");
              newtr.append("<td class='td-status'><span class='label label-success radius'>"+res[i].status+"</span></td>");
             if(res[i].status=='待修改')
                  newtr.append("<td class='td-manage'>"+
					          "<a title='申请' href='javascript:void(0)' onclick=\"admin_edit('修改部门','dept/getbyid.action?id="+res[i].de_id+"&n=2',"+res[i].de_id+",'800','300')\"  class='ml-5' style='text-decoration:none'>"+
					          "<i class='Hui-iconfont'>&#xe6df;</i></a>"+   
				              "</td>");
		      else if(res[i].status=='已删除')  newtr.append("<td class='f-14 td-manage'><a style='text-decoration:none' onClick=\"admin_start(this,'"+res[i].de_id+"')\" href='javascript:;' title='恢复'>恢复</a></td>");
              else newtr.append("<td class='f-14 td-manage' name='aa'><a style='text-decoration:none' onClick=\"article_shenhe(this,'10001')\" href='javascript:;' title='审核'>审核</a></td>");
              $("#deptlist").append(newtr); 
          } 
          
          }); 
       }
       
       $(function(){
         getall();
       })
       
      $(function(){
      
        $("body").on("click","tr td[name=aa]",function(){
            var xx= $(this).parents("tr").find("td:first").html();
            var sta=$(this).parents("tr").find(".td-status span").html();
           
            $("#de_idvv").val(xx);
            $("#statusxx").val(sta);
            
          });
    
          $("#btn").click(function(){
          var ss=$("#formnn").serialize();
          $.get("dept/del.action",ss,function(res){
             alert("sss");
          });
         
           $("#divok").toggle();
           
           alert("提交成功");
       });
      })
       
    </script>


<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 部门 <span class="c-gray en">&gt;</span> 待审批部门 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
  
  <div class="cl pd-5 bg-1 bk-gray mt-20">
   <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
   <a href="javascript:;" onclick="admin_add('添加部门','dept-add.jsp','800','300')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加部门</a></span> <span class="r">共有数据：<strong>54</strong> 条</span> </div>
  </div>
  <table class="table table-border table-bordered table-hover table-bg table-sort">
    <thead>
      <tr class="text-c">
      <!--   <th width="25"><input type="checkbox" name="" value=""></th> -->
        <th width="80">ID</th>
        <th width="100">部门名</th>
        <th width="40">部门经理</th>
        <th width="40">申请人</th>
        <th width="60">状态</th>
        <th width="100">操作</th>
      </tr>
    </thead>
    <tbody id="deptlist">
      <!-- <tr class="text-c">
        <td><input type="checkbox" value="1" name=""></td>
        <td>1</td>
       
        <td><u style="cursor:pointer" class="text-primary" onclick="user_show('10001','360','','张三','user-show.html')">张三</u></td>
        <td>男</td>
        <td>13000000000</td>
        <td>admin@mail.com</td>
        <td class="text-l">北京市 海淀区</td>
        <td>2014-6-11 11:11:42</td>
        <td class="user-status"><span class="label label-success">已启用</span></td>
        <td class="f-14 user-manage"><a style="text-decoration:none" onClick="user_stop(this,'10001')" href="javascript:;" title="停用"><i class="icon-hand-down"></i></a> <a title="编辑" href="javascript:;" onclick="user_edit('4','550','','编辑','user-add.html')" class="ml-5" style="text-decoration:none"><i class="icon-edit"></i></a> <a style="text-decoration:none" class="ml-5" onClick="user_password_edit('10001','370','228','修改密码','user-password-edit.html')" href="javascript:;" title="修改密码"><i class="icon-key"></i></a> <a title="删除" href="javascript:;" onclick="user_del(this,'1')" class="ml-5" style="text-decoration:none"><i class="icon-trash"></i></a></td>
      </tr> -->
    </tbody>
  </table>
  <div id="pageNav" class="pageNav"></div>
  
   <div class="pageNav" style="display:none" id="divok">
       <form  id="formnn">
            <input type="hidden" name="de_id" id="de_idvv" class="input-text"/>
            <input type="hidden" name="status" id="statusxx" class="input-text"/>
            <input type="text" name="de_comm" class="input-text" style="width:150px" placeholder="请输入审核意见"/>
            <input type="button" id="btn" class="btn btn-success radius" value="提交"/>        
       </form>
   </div>
</div>


<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
   /*
	参数解释：
	title	标题
	url		请求的url
	id		需要操作的数据id
	w		弹出层宽度（缺省调默认值）
	h		弹出层高度（缺省调默认值）
*/
/*管理员-增加*/
function admin_add(title,url,w,h){
	layer_show(title,url,w,h);
}
/*审核*/
function article_shenhe(obj,id){

 
	layer.confirm('审核申请？', {
		btn: ['通过','不通过','取消'], 
		shade: false,
		closeBtn: 0
	},
	function(){
		//$(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_start(this,id)" href="javascript:;" title="申请上线">申请上线</a>');
		var sta=$(obj).parents("tr").find(".td-status span").html();
		var id=$(obj).parents("tr").find(".deptid").html();
		var req="status="+sta+"&id="+id;
		$(obj).remove();
		//alert(req);
		location='dept/apply-dept.action?'+req;
		layer.msg('通过', {icon:6,time:1000});
	},
	function(){
		/* var sta=$(obj).parents("tr").find(".td-status span").html();
		var id=$(obj).parents("tr").find(".deptid").html(); */
		var req="status="+sta+"&id="+id;
		$(obj).remove();
		//alert(req);
	    //location='dept/del.action?'+req;
	    $("#divok").css("display","block");
    	//layer.msg('不通过', {icon:5,time:1000});
	});	
	
	

}



/*管理员-编辑*/
function admin_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*管理员-停用*/
function admin_stop(obj,id){
	layer.confirm('确认要停用吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		
		$(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_start(this,id)" href="javascript:;" title="启用" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">已禁用</span>');
		$(obj).remove();
		layer.msg('已停用!',{icon: 5,time:1000});
	});
}

/*管理员-启用*/
function admin_start(obj,id){
	layer.confirm('确认要恢复吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		location='dept/start.action?id='+id;
		layer.msg('已恢复!', {icon: 6,time:1000});
	});
}
</script>
</body>
</html>
